package com.zycfc.zsf.boot.job.common;

import com.zycfc.zsf.boot.job.*;
import com.dangdang.ddframe.job.reg.zookeeper.*;
import com.dangdang.ddframe.job.lite.config.*;
import com.zycfc.zsf.boot.job.core.*;
import org.slf4j.*;

public class SchedulerThread extends Thread
{
    private static final Logger log;
    private ZsfSpringJobScheduler springJobScheduler;
    private ZsfJobProperties jobProperties;
    private String namespace;
    private String applicationName;
    private ZookeeperRegistryCenter zookeeperRegistryCenter;
    private LiteJobConfiguration liteJobConfiguration;
    
    public SchedulerThread(final ZsfSpringJobScheduler springJobScheduler, final ZsfJobProperties jobProperties, final String namespace, final String applicationName, final ZookeeperRegistryCenter zookeeperRegistryCenter, final LiteJobConfiguration liteJobConfiguration) {
        this.springJobScheduler = springJobScheduler;
        this.jobProperties = jobProperties;
        this.namespace = namespace;
        this.applicationName = applicationName;
        this.zookeeperRegistryCenter = zookeeperRegistryCenter;
        this.liteJobConfiguration = liteJobConfiguration;
    }
    
    @Override
    public void run() {
        try {
            Thread.sleep(10000L);
            if (this.springJobScheduler != null) {
                final ZsfJobNodePath jobPath = new ZsfJobNodePath(this.jobProperties.getJobName());
                JobInfPool.put(this.jobProperties.getJobName(), this.jobProperties);
                this.springJobScheduler.init();
                this.zookeeperRegistryCenter.persist(jobPath.getNamespaceNodePath(), this.namespace);
                this.zookeeperRegistryCenter.persist(jobPath.getApplicationNameNodePath(), this.applicationName);
                this.zookeeperRegistryCenter.persist(jobPath.getShardingStrategyNodePath(), this.jobProperties.getShardingStrategy().getValue());
                this.zookeeperRegistryCenter.persist(jobPath.getShardingFixedIpNodePath(), this.jobProperties.getFixedIp());
                SchedulerThread.log.info("^_^ ZsfJob: \u52a0\u8f7d\u4f5c\u4e1a[{}]\u6210\u529f", (Object)this.jobProperties.getJobName());
            }
        }
        catch (Throwable e) {
            SchedulerThread.log.error("ZsfJob: \u52a0\u8f7d\u4f5c\u4e1a[{}]\u5931\u8d25", (Object)this.jobProperties.getJobName(), (Object)e);
        }
    }
    
    static {
        log = LoggerFactory.getLogger((Class)SchedulerThread.class);
    }
}
